/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package azhar.com;

import java.util.ArrayList;

/**
 *
 * @author Al-Insan
 */
public class Separate {

    private String word, statement;
    private ArrayList<String> wordList = new ArrayList<String>();

    private void trimWords(){
        word="";
        for (int i = 0; i < this.statement.length(); i++) {
            if(this.statement.charAt(i)==';'){
                wordList.add(word);
                word="";
            }else{
                word+=this.statement.charAt(i);
            }
        }
    }

    public ArrayList getWord(String statement){
        this.statement = statement;
        if(this.statement.charAt(statement.length()-1)!=';')
            this.statement+=';';
        trimWords();
        return wordList;
    }

    public String separated(String [] words){
        String stat="";
        for (int i = 0; i < words.length; i++) {
            stat = stat+words[i]+';';
        }
        return stat;
    }

}
